package com.gtq.uhome.controller;

import com.gtq.uhome.result.Result;
import com.gtq.uhome.service.DeliveryDetailsService;
import com.gtq.uhome.vo.DeliveryDetailsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping(value = "/deliveryDetails")
@CrossOrigin
@Api(tags = "站点后台——派送详情——待审核——何凡")
public class DeliveryDetailsController {

    @Resource
    DeliveryDetailsService deliveryDetailsService;

    /**
     * 派送详情，待审核，获取审核界面所有数据
     * @param deliveryDetailsVo
     * @return
     */
    @PostMapping
    @ResponseBody
    @ApiOperation(value = "派送详情，待审核，获取审核界面所有数据")
    public Result<List<DeliveryDetailsVo>> findCheckPending(@RequestBody DeliveryDetailsVo deliveryDetailsVo){
        List<DeliveryDetailsVo> deliveryDetails = deliveryDetailsService.findCheckPending(deliveryDetailsVo);
        return Result.ok(deliveryDetails);
    }

    /**
     * 派送详情，待审核，审核界面编辑，更新审核状态
     * @param deliveryDetailsVo
     * @return
     */
    @PutMapping
    @ResponseBody
    @ApiOperation(value = "派送详情，待审核，审核界面编辑，更新审核状态")
    public Result updateDeliveryDetails(@RequestBody List<DeliveryDetailsVo> deliveryDetailsVo){
        Boolean aBoolean = deliveryDetailsService.updateDeliveryDetails(deliveryDetailsVo);
        if (aBoolean){
            return Result.ok("审核完成");
        }
        return Result.failed("审核失败");
    }

}
